<template>
	<view class="diy_tabbar">
		<uv-tabbar :value="current" activeColor="#2380ff" iconSize="24" :safeAreaInsetBottom="safeAreaInsetBottom" @change="diy_tabbar_change">
			<uv-tabbar-item text="首页" icon="home"></uv-tabbar-item>
			<uv-tabbar-item text="学习中心" icon="grid"></uv-tabbar-item>
			<uv-tabbar-item text="考试中心" icon="file-text"></uv-tabbar-item>
			<uv-tabbar-item text="个人中心" icon="account"></uv-tabbar-item>
		</uv-tabbar>
	</view>
</template>

<script>
	export default {
		props:{
			tabbar_index: {
				type: Number,
				default: 0
			},
			insetBottom: {
				type: Boolean,
				default: true
			}
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
			// #ifdef APP-NVUE
			this.scrollTop = e.detail.scrollTop;
			// #endif
		},
		data() {
			return {
				current: this.tabbar_index,
				safeAreaInsetBottom: this.insetBottom,
				scrollTop: 0
			}
		},
		methods: {
			diy_tabbar_change(e) {
				console.log('e',e)
				switch (e) {
					case 0:
						this.current = e;
						uni.reLaunch({
							url: "/pages/index/index"
						})
					break;
					case 1:
						this.current = e;
						uni.reLaunch({
							url: "/pages/category/index"
						})
					break;
					case 2: // 考试中心
						uni.reLaunch({
							// url: "/pages/test/index"
							url: '/exam/pages/room/index'
						})
					break;
					case 3:
						uni.reLaunch({
							// url: "/pages/member/index"
							url: '/exam/pages/user/user'
						})
					break;
					case 4:
					break;
				}
			}
		}
	}
</script>

<style lang="scss">
	.diy_tabbar{
		box-sizing: border-box;
		::v-deep .uv-tabbar--fixed{
			width: 100%;
			left: auto;
			right: auto;
		}
	}
</style>
